# We run this pipeline on a schedule and also developers can run it
# via /azp run command on PRs.
#
# Setting batch to true, triggers one build at a time.
# if there is a push while a build in progress, it will wait,
# until the running build finishes, and produce a build with all the changes
# that happened during the last build.
trigger: none

schedules:
  - cron: "0 9,21 * * *" # run at 9:00 and 21:00 (UTC) which is 1:00 and 13:00 (PST).
    displayName: grpc-dotnet Android client test schedule
    branches:
      include:
      - main
    always: true

variables:
  - template: /eng/pipelines/common/variables.yml

extends:
  template:  /eng/pipelines/common/templates/pipeline-with-resources.yml
  parameters:
    stages:
    - stage: Build
      jobs:

      #
      # Android emulators
      # Build the whole product using Mono and run libraries tests
      #
      - template: /eng/pipelines/common/platform-matrix.yml
        parameters:
          jobTemplate: /eng/pipelines/common/global-build-job.yml
          helixQueuesTemplate: /eng/pipelines/libraries/helix-queues-setup.yml
          buildConfig: Release
          runtimeFlavor: mono
          platforms:
          - android_x64_docker
          jobParameters:
            testGroup: innerloop
            nameSuffix: AllSubsets_Mono_gRPC
            buildArgs: -s mono+libs+host+packs+libs.tests -c $(_BuildConfig) /p:ArchiveTests=true /p:RunGrpcTestsOnly=true /p:BuildGrpcServerDockerImage=true
            timeoutInMinutes: 180
            # extra steps, run tests
            postBuildSteps:
              - template: /eng/pipelines/libraries/helix.yml
                parameters:
                  creator: dotnet-bot
                  extraHelixArguments: /p:RunGrpcTestsOnly=true /p:BuildGrpcServerDockerImage=true
                  testRunNamePrefixSuffix: Mono_$(_BuildConfig)
